﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Workflow2211A.Consol.Data;
using Workflow2211A.Consol.Steps;
using WorkflowCore.Interface;

namespace Workflow2211A.Consol.Workflows
{
    public class IfWorkflow : IWorkflow<LoopData>
    {
        public string Id => nameof(IfWorkflow);

        public int Version => 1;

        public void Build(IWorkflowBuilder<LoopData> builder)
        {
            builder.StartWith<StartStep>()
                   .If(data => data.LoopCount == 1)
                   .Do(x =>
                   {
                       x.Then<TaskA>()
                       .Then<TaskB>()
                       .Then<TaskC>()
                       .Then<TaskD>();
                   })
                   .If(data => data.LoopCount == 2)
                   .Do(x =>
                   {
                       x.Then<TaskB>()
                      .Then<TaskC>()
                      .Then<TaskD>();
                   })
                   .If(data => data.LoopCount == 3)
                   .Do(x =>
                   {
                       x.Then<TaskC>()
                       .Then<TaskD>();
                   })
                   .If(data => data.LoopCount == 4)
                   .Do(x =>
                   {
                       x.Then<TaskD>();
                   }).Then<EndStep>();


        }
    }
}
